/*
********************************************************************************
* Copyright (C) 2021, xiang.D <dx_65535@163.com>.
* All right reserved.
*
* File Name   : aggregate.h
* Author      :
* Version     : V1.0
* Description :
* Journal     : 2021-02-19 init v1.0
* Brief       : Blog: https://blog.csdn.net/qq_38750572?spm=1001.2014.3001.5343
* Others      :
********************************************************************************
*/

#ifndef __AGGREGATE_H__
#define __AGGREGATE_H__

#include <vector>
#include "aggregatebase.h"

#define AGG_LOGI(fmt, args...) printf(fmt, ##args)
#define AGG_LOGE(fmt, args...) printf("%d Aggregate E: " fmt, __LINE__, ##args)

template <class T>
class CIterator;

template <typename T>
class CAggregate : public CAggregateBase<T>
{
    friend class CIterator <T>;

public:
    CAggregate() : mIterator(NULL)
    {

    }

    ~CAggregate()
    {
        if (mIterator) {
            delete mIterator;
        }
    }

    void push_back(T data)
    {
        mData.push_back(data);
    }

private:
    std::vector<T> mData;
    CIteratorBase<T>* mIterator;
};

#endif

